import {Request, Response} from 'express'
import {Controller, Get, Post, Auth, generateToken} from '../uitl'
// import UserService from '../service/userService'

@Controller('/user')
class UserController {
  @Post('/login')
  public login(
    req: Request,
    res: Response
  ): Response<any, Record<string, any>> {
    console.log(req.body)
    return res.send({
      success: true,
      data: {},
      token: generateToken('testttt'),
    })
  }

  // 装饰器 就近执行 先Auth, 再Post
  @Post('/reset/:id')
  @Auth
  public reset(
    req: Request,
    res: Response
  ): Response<any, Record<string, any>> {
    return res.send({success: true, data: 'reset' + req.params.id})
  }
}

export default UserController
